﻿local QI = DailyIntake.QuestItems;
local Localize = DailyIntake.Localize;

-- Add item: Renewing Tourniquet; http://www.wowhead.com/?item=37568
local function RenewingTourniquet()
    return UnitOnTaxi("player") ~= 1
        
        -- must target Wounded Skirmisher; http://www.wowhead.com/?npc=27463
        and QI.UnitIsEntity("target", 27463, QI.Entity.Mob)
        
        -- Wounded Skirmisher must be alive
        and not UnitIsDead("target")
        
        -- must not be tapped by other players
        and not QI.UnitIsTappedByOtherPlayer("target")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(12288);
end;
QI.RegisterQuestItem(37568, QI.Priority.High, RenewingTourniquet);

-- Add item: Warts-B-Gone Lip Balm; http://www.wowhead.com/?item=44986
local function WartsBGoneLipBalm()
    local result = 
        not UnitOnTaxi("player")
        
        -- must be in propper location
        and GetZoneText() == Localize("Grizzly Hills")
        and QI.PlayerIsInArea(0.48, 0.60, 0.52, 0.62)
                
        -- must not have completed quest objective yet
        and not (QI.QuestIsDone(13603) or
                 QI.QuestIsDone(13666) or
                 QI.QuestIsDone(13673) or
                 QI.QuestIsDone(13741) or
                 QI.QuestIsDone(13746) or
                 QI.QuestIsDone(13752) or
                 QI.QuestIsDone(13757) or
                 QI.QuestIsDone(13762) or
                 QI.QuestIsDone(13768) or
                 QI.QuestIsDone(13773) or
                 QI.QuestIsDone(13778) or
                 QI.QuestIsDone(13783)
                 );
    
    
    if not result then return; end;
    
    -- in case we target the wrong frog - display error message
    --if QI.UnitIsEntity("target", 33211, QI.Entity.Mob) then
    --    return true, "/script UIErrorsFrame:AddMessage(\"" .. DailyIntake.Localize("This frog will not turn into the maiden.") .. "\", 1.0, 0.3, 0.3, 53, 5);"
	 --   .. "PlaySoundFile(\"Sound\\\\Interface\\\\Error.wav\");", 536;
    --end;
    
    -- in case we target the right frog - then proceed further
--geterrorhandler()(QI.Entity.Mob)    
--    if QI.UnitIsEntity("target", 33224, QI.Entity.Mob)
        
        -- must not be tapped by other players
--        and not QI.UnitIsTappedByOtherPlayer("target") then
    
            -- if no balm buff then need to have it first
            if not QI.PlayerHasBuff("Warts-B-Gone Lip Balm") then
                
                    startTime, duration, enable = GetItemCooldown(44986);
                    if duartion and duration > 0 then
                        return true, "#showtooltip item:44986\n/cleartarget\n/tar Lake Frog\n/kiss\n/run DailyIntake.QuestItems.RefreshMacro()\n";
                    else
                        return true, "#showtooltip item:44986\n/use item:44986\n/cleartarget\n/tar Lake Frog\n/kiss\n/run DailyIntake.QuestItems.RefreshMacro()\n";
                    end;
                    
            else -- we have the buff
            
                return true, "#showtooltip item:44986\n/cleartarget\n/tar Lake Frog\n/kiss\n/run DailyIntake.QuestItems.RefreshMacro()\n", 1049;
            
            end;
            
  
--    end;
    
end;
QI.RegisterQuestItem(44986, QI.Priority.Normal, WartsBGoneLipBalm);

-- Add item: Mack's Dark Grog; http://www.wowhead.com/?item=35908
local function MacksDarkGrog()
    return not UnitOnTaxi("player")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(12038) -- Seared Scourge (http://www.wowhead.com/?quest=12038)
        
        -- must be in right location
        and GetZoneText() == Localize("Grizzly Hills")
        and QI.PlayerIsInArea(0.26, 0.145, 0.31, 0.216);
end;
QI.RegisterQuestItem(35908, QI.Priority.Normal, MacksDarkGrog);

-- Add item: Smoke Bomb; http://www.wowhead.com/?item=37621
local function SmokeBomb()
    return not UnitOnTaxi("player")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(12323) -- Smoke 'Em Out (Alliance) (http://www.wowhead.com/?quest=12323)
        and not QI.QuestIsDone(12324) -- Smoke 'Em Out (Horde)    (http://www.wowhead.com/?quest=12324)
        
        -- must be in right location
        and GetZoneText() == Localize("Grizzly Hills")
        
        and (QI.PlayerIsCloseTo(0.14544755220413, 0.76376765966415, 0.012) or
             QI.PlayerIsCloseTo(0.16440019011497, 0.76428210735321, 0.012) or
             QI.PlayerIsCloseTo(0.17976811528206, 0.79592043161392, 0.012)
             );
end;
QI.RegisterQuestItem(37621, QI.Priority.Normal, SmokeBomb);


